package com.yuwei.home.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.yuwei.common.entity.MenuEntity
import com.yuwei.home.databinding.HomeMenuItemBinding

class HotServiceAdapter(private val data : MutableList<MenuEntity>) : RecyclerView.Adapter<HotServiceAdapter.HotItemViewHolder>(){
    inner class HotItemViewHolder(val binding : HomeMenuItemBinding) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HotItemViewHolder {
        val inflate =
            HomeMenuItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return HotItemViewHolder(inflate)
    }

    override fun getItemCount(): Int = data.size

    override fun onBindViewHolder(holder: HotItemViewHolder, position: Int) {
        val item = data[position]
        Glide.with(holder.itemView.context).load(item.image).into(holder.binding.homeMenuImage)
        holder.binding.homeMenuTitle.text = item.title

    }
}